import request from './request.js'
import { Decrypt } from '@/utils/aes.js'

// 账号密码登录接口
export function getAllVips(){
    return request({
        url:'/api/vip/getAllVips',
        method:'POST'
    })
}

// 去结算
export function settlement({id,token}){
    return request({
        url:'/api/vip/settlement',
        method:'GET',
        params:{id},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token')),
            'token':token
        }
    })
}

//微信支付
export function wxpay({vipId,payModes,token}){
    return request({
        url:'/api/vip/wxpay/createOrder',
        method:'POST',
        data:{vipId,payModes,isRenew: 0},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token')),
            'token':token
        }
    })
}

//支付宝支付
export function zfbpay({vipId,payModes,token}){
    return request({
        url:'/api/vip/alipay/createOrder',
        method:'POST',
        data:{vipId,payModes,isRenew: 0},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token')),
            'token':token
        }
    })
}

//兑换
export function doExchange({exchangeCode,token}){
    return request({
        url:'/api/exchange/doExchange',
        method:'GET',
        params:{exchangeCode},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token')),
            'token':token
        }
    })
}